// 某个模块的数据请求（增删改查！）

import $axios from "@/common/http";  // 封装的axios
import axios from "axios"   // 原生的axios
import { Message } from "element-ui"  // 提示框


export async function getSeckill(id) {
    let res;
    if (id) {
        res = await $axios.get("/seckinfo", { params: { id } });
    } else {
        res = await $axios.get("/secklist");
    }
    return res.list;
}

export async function addSeckill(data) {
    let res = await $axios.post("/seckadd", data);
    Message.success(res.msg)
    return true;
}

export async function editSeckill(data) {
    let res = await $axios.post("/seckedit", data);
    Message.success(res.msg)
    return true;
}

export async function delSeckill(id) {
    if (!id) {
        Message.warning("请传入删除id");
        return;
    }
    let res = await $axios.post("/seckdelete", { id })
    Message.success(res.msg)
    return res.list;
}